<?php
include("connect.php");
?>


<?php
$folder_position = getcwd().DIRECTORY_SEPARATOR;

if($_FILES["img1"]["error"]>0)
	{
	
	}else
	{
		$link1 = $_SESSION['userid']."_".strtotime('now')."_".$_FILES["img1"]["name"];		
		$target_img1 = $folder_position . "images/my_profile/".$link1;
		move_uploaded_file($_FILES["img1"]["tmp_name"],$target_img1);
		$value .= "photolink = '".$link1."',";
	}	
$userid=$_SESSION[userid];
$sql="UPDATE m_user SET ";

if(!empty($_POST[fname])){
	$value .= "fname = '".$_POST[fname]."',";
}
if(!empty($_POST[lname])){
	$value .= "lname = '".$_POST[lname]."',";
}
if(!empty($_POST[mobilephone])){
	$value .= "phonenumber = '".$_POST[mobilephone]."',";
}
if(!empty($_POST[nationality])){
	$value .= "nationality = '".$_POST[nationality]."',";
}
if(!empty($_POST[address])){
	$value .= "address = '".$_POST[address]."',";
}
if(!empty($_POST[post_code])){
	$value .= "postcode = '".$_POST[post_code]."',";
}
if($_POST[course]!=0){

	$value .= "course_id = '".$_POST[course]."',";
	
	if($_POST[major1]!=0){
		$value .= "course_category_id = '".$_POST[major1]."',";
	}
}

if(!empty($_POST[fbemail])){
	$value .= "fb_account = '".$_POST[fbemail]."',";
}

if(!empty($_POST[twitterid])){
	$value .= "twitter_account = '".$_POST[twitterid]."'";
}

$last = $value[strlen($value)-1];
$last_number=strlen($value)-1;

if($last==","){
	$value=substr($value,0,$last_number);
}

$sql .= $value." WHERE user_id='".$userid."'";


$result = mysql_query($sql);

if($result){
?>
<script type="text/javascript">
<!--
alert('Profile has been edited');
//-->
</script>
<?
}
	include ("my_profile.php");



?>